#include <iostream>
using namespace std;
#include <vector>

vector<int> cur;
vector<int> temp;

int main()
{
    int n;
    cur.reserve(1001);
    temp.reserve(1001);
    while (cin >> n)
    {
        for (int i = 0, a; i <= n; i++)
        {
            cur.push_back(i);
        }
        while (cur.size() != 1)
        {
            temp.clear();
            for (size_t i = 0; i < cur.size(); i++)
            {
                if (i % 2 == 1)
                {
                    temp.push_back(cur[i]);
                }
            }
            cur.swap(temp);
            // for(size_t i = 0; i < cur.size() ;i++)
            //     cout << cur[i] << " ";
            // cout << endl;
        }
        cout << *cur.begin() << endl;
        cur.clear();
    }

    return 0;
}